package com.example.battery;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;

public class Broadcast extends BroadcastReceiver {
	
	 int notifyID=1;
	
	//public Context context;


	//ConnectivityManager connectivityManager;
	
	 // ConnectivityManager connMgr = (ConnectivityManager) context
      //       .getSystemService(Context.CONNECTIVITY_SERVICE);
	 
	// android.net.NetworkInfo wifi = connMgr
           //  .getNetworkInfo(ConnectivityManager.TYPE_WIFI);

	 
	 
	 //NetworkInfo activeNetwork = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

	
	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		
		
		
		System.out.println("Ajay");
		 @SuppressWarnings("unused")
		String action = intent.getAction();
		 int currentLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
         int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
         int level = -1;
         if (currentLevel >= 0 && scale > 0) {
             level = (currentLevel * 100) / scale;
         }
		 
		 
         if(level <= 20 ){
        	 
         System.out.println("Ay"+level);
        	 setwifiEnabled(false);
        	
		 }
   	
	}
	
	private void setwifiEnabled(boolean b) {
		// TODO Auto-generated method stub
		
	}

}
